#ifndef SVE_NETWORK_H
#define SVE_NETWORK_H
#include <QtNetwork>
#include <QtGui>
#include <QtSql>

class sve_network : public QTcpServer
{
    Q_OBJECT
    Q_ENUMS(cmmds)
    //Q_ENUMS(Rx2Client)

public:
// Variables

    enum cmmds {
            M1msg,
            M6msg,
            invalidM1,
            hearing,
            invalidID,
            wrongHash,
            invalidVote,
            voteSaved
        };

    int delay_server; // Variable que contiene el tiempo máximo(ms) que se espera una respuesta por parte del cliente
    QTcpServer *tcpServer;
    QTcpSocket *clientConnection;
    QNetworkSession *networkSession;
    QString msg_RX;
    QString msg_TX;

// Funciones
    sve_network(QWidget *parent=0);
    ~sve_network();
    bool open_server();
    void close_server();

    void send_msg(QString msg, QTcpSocket &client);
    bool read_msg(QString &msg,QTcpSocket &client);
    QString shift_String(QString &msg);
    QStringList show_interfaces();
    QStringList interface_info(QString interface_name);
    void reg_nodo(QString IP, QString ID);
    bool chk_IP(QString IP);


private:
// Variables
    quint16 blockSize;

// Funciones
    bool chk_Client();

    int show_msg(QString message,QString info ="",QString detail = "", QMessageBox::Icon icono = QMessageBox::Information,QMessageBox::StandardButtons buttons=QMessageBox::Ok);


signals:
    void req_prop();
    void new_user();
    void M1_signal();
    void M6_signal();
    void config_signal();


private slots:
    bool voting_Connection();
    void config_Connection();
    //void nv_result();



};







#endif // SVE_NETWORK_H
